package com.zlcx.tz.live.constant;

/**
 * <p>麦克状态</p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期         修改人          修改内容
 * </PRE>
 * @author zl
 * @date Created in 2019/4/18 14:43
 * @version 1.0
 * @copyright: Copyright (c) founders
 */

public enum PublisherStatus {

    APPLYING("applying", "申请中", 1),
    PUBLISHING("publishing", "上麦中", 2),
    CANCEL("cancel", "已取消", 3),
    QUIT("quit", "已下麦", 4),
    FORCEQUIT("forcequit", "被强制踢出", 5)
    ;

    PublisherStatus(String info, String tips, int code) {
        this.info = info;
        this.tips = tips;
        this.code = code;
    }

    public  static PublisherStatus create(Integer code) {
        if (null == code) {
            return null;
        }
        for (PublisherStatus statusEnum : PublisherStatus.values()) {
            if (code == statusEnum.getCode()) {
                return statusEnum;
            }
        }
        return null;
    }

    private String info;
    private String tips;
    private int code;

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getTips() {
        return tips;
    }

    public void setTips(String tips) {
        this.tips = tips;
    }

    public static PublisherStatus getPublisherStatus(int code) {
        for (PublisherStatus field : PublisherStatus.values()) {
            if (code == field.getCode()) {
                return field;
            }
        }
        return null;
    }

    public static boolean isValidStatus(int code) {
        if(code == APPLYING.code || code == PUBLISHING.code ){
            return true;
        }
        return false;
    }

}
